<template>
	<view class="web-view-container">

		<!-- <web-view :src="targetUrl"></web-view> -->
		微信授权中
	</view>
</template>
<script>
	const app = getApp();
	export default {
		data() {
			return {

			}
		},
		onLoad() {
			// let add=uni.getCurrentPages()	
			// let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
			// let curRoute = routes[routes.length - 1].route //获取当前页面路由
			// let curParam = routes[routes.length - 1].options; //获取路由参数
			let add = window.location.href
			console.log(add, '411')
			let index = add.indexOf('code=');
			if (index !== -1) {
				let codeValue = add.slice(index + 5).split('&')[0];
				console.log(typeof codeValue, '456456');
				console.log(codeValue, '455');
				app.globalData.api.request(`weichat/get_openid?code=${codeValue}`, 'GET').then((res => {
					// console.log(res, 'resres')
					if (res && res.openid) {
						uni.setStorageSync('openId', res.openid);
						// console.log(openId, 'resres')
						// uni.navigateTo({
						// 	url: '/pages/login/index'
						// })
						window.location.href = 'https://saas.mmchengren.com/#/pages/login/index'
					} else {
						console.log('跳转失败');
					}

				}))
			}

			// console.log(routes, '1111')
			// console.log(curRoute, '2111')
			// console.log(curParam, '3111')



		}
	};
</script>
<style>
	.web-view-container {
		width: 100%;
		text-align: center;
		color: gray;
		font-size: 50rpx;
	}
</style>